<include file="Public/header.html"/>
</head>
<body>
	<div class="x-nav">
		<span class="layui-breadcrumb">
		  <a><cite>首页</cite></a>
		  <a><cite>项目管理</cite></a>
		  <a><cite>分类列表</cite></a>
		</span>
		<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right;height:30px;padding: 0 15px;"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
	</div>
	<div class="x-body">
		<form class="layui-form x-center" action="{:U('Home/Web/Project/class_list')}" method="post">
			<div class="layui-form-pane" style="margin-top: 15px;">
				<div class="layui-form-item">             	                            
					<div class="layui-input-inline" style="width: 140px;">
						<input type="text" name="name" placeholder="请输入分类名" value="{$name}"  autocomplete="off" class="layui-input">
					</div>
					<div class="layui-input-inline" style="width:80px">
						<button class="layui-btn" type="submit"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
					</div>
				</div>
			</div> 
		</form>
		<xblock> 
			<button class="layui-btn" onclick="class_add('添加项目分类','{:U('Home/Web/Project/class_add')}','800','300')"><i class="layui-icon">&#xe608;</i>添加</button>
		</xblock>
		<form id="delform" class="layui-form">
			<table class="layui-table">
				<thead>
					<tr>
						<th>ID</th>
						<th>分类名</th>
						<th>操作时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="formdata">
					<volist name="list" id="vo">
						<tr>
							<td>{$vo.id}</td>
							<td>{$vo.name}</td>
							<td><?php echo date('Y-m-d H:i:s', $vo['update_time']); ?></td>
							<td class="td-manage">
								<span class="layui-btn layui-btn-xs" onclick="class_add('编辑','{:U('Home/Web/Project/class_add',array('id'=>$vo['id']))}','800','300')">编辑</span>
								<span class="layui-btn layui-btn-xs layui-btn-danger" onclick="class_del('{$vo['id']}')">删除</span>
							</td>
						</tr>
					</volist>
				</tbody>
			</table>
		</form>
		<span class="x-right" style="line-height:40px">共有数据：{$count} 条</span>
		<div id="page"></div>
	</div>
<include file="Public/footer.html"/>
<script type="text/javascript" src="__ROOT__/Public/js/jquery.min.js"></script> 
<script>
	layui.use(['form','laypage','layer','element'], function(){
		laypage = layui.laypage;//分页
		layer = layui.layer;//弹出层
		form = layui.form;
	  
		laypage.render({
			elem: 'page',
			count: "{$count}",
			limit: "{$limit}",
			curr : "{$page}", 
			jump: function(obj, first){
			   if(!first){
				var $purl = "{:U('Home/Web/Project/class_list',array('page'=>'pageval','name'=>$name))}";
				window.location.href= $purl.replace('pageval',obj.curr);
			   }
			}
		});
	});
	function class_add(title,url,w,h){
		if (title == null || title == '') {
			title=false;
		};
		if (url == null || url == '') {
			url="404.html";
		};
		if (w == null || w == '') {
			w=800;
		};
		if (h == null || h == '') {
			h=($(window).height() - 50);
		};
		
		var index = layer.open({
			id:'ch',
			type: 2,
			area: [w+'px',h +'px'],
			fix: false, //不固定
			maxmin: true,
			shadeClose: true,
			shade:0.4,
			title: title,
			content: url,
			btn: ['提交'] ,
			yes: function(index, layero){
				var body = layer.getChildFrame('body', index);
				body.find("#submitBtn").click();
				return false;
			}
		});
	}
	
	function class_del(id){
		layer.confirm('确认要删除吗？',function(index){
			$.ajax({
				url: "{:U('Home/Web/Project/class_del')}",
				type : "POST",
				data :{"id":id},
				dataType:"text",     
				success:function(data){
					if(data == '1'){
						layer.msg('提交成功', {icon: 1,offset: '40%',time:2000,shade: 0.3},function(){ 
							location.reload();
						})
					}else if(data == '2'){
						layer.msg('提交失败', {icon: 2,offset: '40%',time:2000,shade: 0.3});
					}else{
						layer.msg(data, {icon: 2,offset: '40%',time:2000,shade: 0.3});
					}
				}
			});
	   });
	}
</script>
</body>
</html>
